﻿using Contracts;
using DataAccess;
using DataObjects;
using DreamDriven.ObjectModel.BusinessLogic;

namespace BusinessLogic
{
    /// <summary>
    /// Represents the Domain Model
    /// </summary>
    public sealed class DomainModel : AbstractDomainModel, IService
    {
        /// <summary>
        /// Gets the registred repository.
        /// </summary>
        /// <value>The repository.</value>
        internal Repository Repository
        {
            get { return (Repository) GetRepository<DataObject>(); }
        }

        /// <summary>
        /// Gets the registred business logic manager.
        /// </summary>
        /// <value>The business logic manager.</value>
        public BusinessLogicManager BusinessLogicManager
        {
            get { return GetBusinessLogicManager<BusinessLogicManager>(); }
        }

        /// <summary>
        /// Constructor must be private: DomainModel creates by ServiceLocator
        /// </summary>
        /// <param name="serviceName"></param>
        private DomainModel(string serviceName)
            : base(serviceName)
        {
            //Possibly to register more than one Business Logic Manager
            RegisterBusinessLogicManager(new BusinessLogicManager(this));

            //Possibly to register more than one Repository
            RegisterRepository(new Repository(this));
        }

        #region Implementation of IService

        public void DoSomething()
        {
            BusinessLogicManager.DoSomething();
        }

        #endregion
    }
}